Colors {
    Colors.darkpurple = rgba(0.549,0.565,0.757, 0.2)
    Colors.black = rgba(0.0, 0.0, 0.0, 1.0)
}

Set x {
    x.shape = Circle {
        strokeWidth : 1.0
        strokeColor : Colors.black
        color: Colors.darkpurple
    }

    x.text = Text {
        string : x.label
        fontSize: "20pt"
    }

    x.labelFn = ensure contains(x.shape, x.text)
    x.minSizeFn = ensure minSize(x.shape)
    x.maxSizeFn = ensure maxSize(x.shape)
    x.layering  = x.shape below x.text
}


Set x; Set y
where IsSubset(x, y) {
    x.containFn = ensure contains(y.shape, x.shape, 20.0)
    x.sizeFn    = ensure smallerThan(x.shape, y.shape)
    y.outsideFn = ensure outsideOf(y.text, x.shape)
}

Set x; Set y; Set z
where IsSubset(x, y); IsSubset(y, z); {
    z.outsideFn = ensure outsideOf(z.text, x.shape)
    z.outsideFn = ensure outsideOf(z.text, y.shape)
}


Set x; Set y
where IsSubset(x, y); IsSubset(y, x); {
    delete x.containFn 
    delete x.sizeFn    
    delete x.outsideFn 

    y.text = Text {
        string: concat(y.label, "=", x.label)
        fontSize: "20pt"
    }

    y.labelFn = ensure contains(y.shape, y.text)
    y.centerFn = encourage sameCenter(x.shape, y.shape)
    y.eqFn = encourage equal(x.shape.r, y.shape.r)
    -- y.layering = y.shape below y.text

    delete x.text
    delete x.labelFn
    delete x.layering
    delete x.centerFn 
    delete x.eqFn 
}

-- This block is just for A=B<-C
Set x; Set y; Set z
where IsSubset(x, y); IsSubset(y, x); IsSubset(z, x) {
    delete x.labelFn 
    delete x.text 
    delete x.outsideFn 

    y.text = Text {
        string: concat(y.label, "=", x.label)
        fontSize: "20pt"
    } 
    y.labelFn = ensure contains(y.shape, y.text)
    y.outsideFn = ensure outsideOf(y.text, z.shape)
}

Set x; Set y; Set z
where IsSubset(x, y); IsSubset(y, x); IsSubset(x, z) {
    z.containFn = ensure contains(z.shape, x.shape, 20.0)
}

Set x; Set y; Set z
where IsSubset(x, y); IsSubset(y, z); IsSubset(z, x) {
    delete x.text
    delete x.labelFn
    delete x.layering
    delete y.text
    delete y.labelFn
    delete y.layering
    delete z.containFn
    delete x.containFn
    delete y.containFn

    z.text = Text {
        string: concat(z.label, "=", y.label, "=", x.label)
        fontSize: "20pt"
    }
    z.labelFn = ensure contains(z.shape, z.text)
    z.centerFn = encourage sameCenter(x.shape, y.shape)
    z.centerFn2 = encourage sameCenter(x.shape, z.shape)
    z.centerFn2 = encourage sameCenter(y.shape, z.shape)

    LOCAL.r = ?
    x.shape.r = LOCAL.r
    y.shape.r = LOCAL.r
    z.shape.r = LOCAL.r
}

Set x; Set y; Set z
where IsSubset(x, z); IsSubset(y, z); IsSubset(z, x); IsSubset(z, y) {
    delete x.text
    delete x.labelFn
    delete x.layering
    delete y.text
    delete y.labelFn
    delete y.layering
    delete z.containFn
    delete x.containFn
    delete y.containFn
    delete z.outsideFn
    delete x.outsideFn
    delete y.outsideFn

    LOCAL.r = ?

    z.text = Text {
        string: concat(z.label, "=", y.label, "=", x.label)
        fontSize: "20pt"
    }
    z.labelFn = ensure contains(z.shape, z.text)
    z.centerFn = encourage sameCenter(x.shape, y.shape)
    z.centerFn2 = encourage sameCenter(x.shape, z.shape)
    x.shape.r = LOCAL.r
    y.shape.r = LOCAL.r
    z.shape.r = LOCAL.r
}
